using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Xml;

namespace Engine
{
    public class Setting
    {
        // Doc tat ca cac file config
        public static Config ReadConfig() 
        {
            ArrayList hosts = new ArrayList();
            XmlDocument xdoc = new XmlDocument();
            xdoc.Load("Ftpconfig.xml");

            XmlNodeList proxy = xdoc.GetElementsByTagName("Proxy");
            string attrValue = proxy[0].Attributes[0].Value;
            bool active = false;
            if (attrValue.CompareTo("1") == 0)
                active = true;

            XmlNodeList user = xdoc.GetElementsByTagName("username");
            XmlNodeList pass = xdoc.GetElementsByTagName("password");
            XmlNodeList domain = xdoc.GetElementsByTagName("domain");
            XmlNodeList serverProxy = xdoc.GetElementsByTagName("serverProxy");

            // Lay cac gia tri cau hinh
            XmlNodeList server = xdoc.GetElementsByTagName("server");
            XmlNodeList pathXml = xdoc.GetElementsByTagName("pathXml");
            XmlNodeList pathImage = xdoc.GetElementsByTagName("pathImage");
            XmlNodeList dataService = xdoc.GetElementsByTagName("dataService");
            XmlNodeList fileService = xdoc.GetElementsByTagName("fileService");

            return new Config(server[0].InnerText, pathXml[0].InnerText,pathImage[0].InnerText,active,user[0].InnerText
                              , pass[0].InnerText,domain[0].InnerText,serverProxy[0].InnerText,dataService[0].InnerText,fileService[0].InnerText);
        }
    }
}
